package com.ruoyi.system.outto.game.impl;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.model.domain.AccountInfo;
import com.ruoyi.system.model.domain.InfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.core.OutUrlConstant;
import com.ruoyi.system.outto.core.RegionalCovert;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.game.IMMAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;

/**
 * @author lz
 * @version 1.0
 * @date 2022/6/14 15:28
 */
@Slf4j
@Service
public class MMAPIImpl implements IMMAPI {

    @Resource
    private InfoImgMapper infoImgMapper;
    @Autowired
    private CommonApi commonApi;

    @Value("${mima.baseUrl}")
    private String MMMBaseUrl;
    @Value("${desc.title}")
    private String descTitle;
    private SalePartner salePartner;

    @Override
    public AjaxResult addAndEditGame(AccountInfo accountInfo,Long userId, SalePartner salePartner) {
        this.salePartner = salePartner;
        Map<String, Object> params = params(accountInfo,salePartner);
        String paramsStr = JSONObject.toJSONString(params);
        log.info("米马添加请求参数：" + paramsStr);
        String response = HttpUtils.sendPost(salePartner.getTwoOther()+"/publish", paramsStr,"application/json");
        log.info("米马添加返回参数：" +response);
        JSONObject resultJson = JSONObject.parseObject(response);

        Map<String, Object> result = new HashMap<>();
        if (!"0".equals(resultJson.getString("code"))){
            result.put("code",500);
        }else {
            result.put("code",200);
        }

        result.put("req",JSONObject.toJSONString(params));
        result.put("res",response);
        result.put("msg",resultJson.getString("msg"));
        return AjaxResult.success(result);
    }
    @Override
    public AjaxResult delGame(Long id,int action,Long userId, SalePartner salePartner) {

        JSONObject params = new JSONObject();
        params.put("appid",salePartner.getSaleKey());
        params.put("secret",salePartner.getOther());
        params.put("action",action);
        params.put("out_goods_id",id);
        String paramsStr = JSONObject.toJSONString(params);
        if(action==1){
            log.info("米马上架请求参数：" + paramsStr);
        }else{
            log.info("米马下架请求参数：" + paramsStr);
        }
        String response = HttpUtils.sendPost(salePartner.getTwoOther()+"/action", paramsStr,"application/json");
        if(action==1) {
            log.info("米马上架返回参数：" + response);
        }else{
            log.info("米马下架返回参数：" + response);
        }
        JSONObject resultJson = JSONObject.parseObject(response);

        Map<String, Object> result = new HashMap<>();
        if (!"0".equals(resultJson.getString("code"))){
            result.put("code",500);
        }else {
            result.put("code",200);
        }
        result.put("req",JSONObject.toJSONString(params));
        result.put("res",response);
        result.put("msg",resultJson.getString("msg"));
        return AjaxResult.success(result);
    }

    private String baseUrl(){
        return OutUrlConstant.MMMURL.replace("base",MMMBaseUrl);
    }

    private Map<String,Object> params(AccountInfo accountInfo,SalePartner sa) {

        String engGameType = getEngGameType(accountInfo.getType());
        if (!StringUtils.isNull(engGameType)){
            JSONObject params = new JSONObject();

            params.put("appid", this.salePartner.getSaleKey());
            params.put("secret", this.salePartner.getOther());
            params.put("game",engGameType);
            String title = accountInfo.getDes();
            if (accountInfo.getDes().length() > 150){
                title = accountInfo.getDes().substring(0,150);
            }
            params.put("title","【"+descTitle + "_"+ accountInfo.getId() +"】  " + accountInfo.getLevel() + "  "  + title);
            params.put("desc",accountInfo.getDes());
            params.put("account","123456789");
            if("CF端游".equals(accountInfo.getType())){
                String string = RegionalCovert.toCF(accountInfo.getRegional(),accountInfo.getDes());
                params.put("partition", string);
            }else {
                if (Arrays.asList(LCConstant.CoverGames).contains(accountInfo.getType())) {
                    String regional = RegionalCovert.toMM(accountInfo.getRegional());
                    if (StringUtils.isEmpty(regional)) {
                        throw new GlobalException("大区转换失败，当前系统大区是" + accountInfo.getRegional());
                    }
                    if("英雄联盟".equals(accountInfo.getType())){
                        String string = RegionalCovert.dianxin+","+RegionalCovert.wangtong+","+RegionalCovert.quanwangluo;
                        if(string.contains(accountInfo.getRegional())){
                            params.put("partition", regional+" "+accountInfo.getRegional());
                        }
                    }else {
                        params.put("partition", regional);
                    }
                } else {
                    params.put("partition", accountInfo.getRegional());
                }
            }
            BigDecimal bigDecimal = commonApi.addPrice(accountInfo.getPrice(), sa.getSeleep());
            commonApi.setPrice(bigDecimal,accountInfo.getId(),sa);
            params.put("price",bigDecimal);
            List<JSONObject> attrs = new ArrayList<>();
            JSONObject att = new JSONObject();
            att.put("有无防沉迷","无防沉迷");
            att.put("账号来源","我是原号主");
            if("王者荣耀".equals(accountInfo.getType())){
                att.put("英雄数量",accountInfo.getHeroes());
                att.put("皮肤数量",accountInfo.getSkins());
                String string = "九霄神辉,星域神启,全息碎影,星空梦想,天鹅之梦,无限飓风号,杀手不太冷,大秦宣太后,倪克斯神谕,活力突击,鸣剑·曳影";
                String [] strings = string.split(",");
                String dzpf = "";
                for(String s : strings) {
                    if (accountInfo.getDes().contains(s)) {
                        dzpf+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(dzpf)){
                    att.put("典藏皮肤",dzpf.substring(1));
                }
                String string1 = "武则天,艾琳,韩信,夏洛特,娜可露露,橘右京,不知火舞,嬴政";
                String [] string1s = string1.split(",");
                String xyyx = "";
                for(String s : string1s) {
                    if (accountInfo.getDes().contains(s)) {
                        xyyx+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(xyyx)) {
                    att.put("稀有英雄", xyyx.substring(1));
                }
                String string2 = "金色仲夏夜,幽冥火,幽冥之眼,幻海之心,未来机甲,零号雷霆";
                String [] string2s = string2.split(",");
                String xypf = "";
                for(String s : string2s) {
                    if (accountInfo.getDes().contains(s)) {
                        xypf+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(xypf)){
                    att.put("星元皮肤",xypf.substring(1));
                }
                String string3 = "大圣娶亲,至尊宝,天狼溯光者,太华,乒乒小将,一生所爱,凤求凰,青龙志,烈魂,逐梦之翼,蜜橘之夏,天狼绘梦者,玄武志,冰霜恋舞曲,逐梦之音,繁星吟游,奇迹圣诞,幽恒,虎魄,玄嵩,云端筑梦师,朱雀志,霸王别姬,逐梦之光,神奇女侠,真爱至上,凤凰于飞,飞衡,逐梦之影,岱宗,纯白花嫁,青春决赛季,瑞麟志,时之彼端,热情桑巴,白虎志,逐梦之星,梅西,天狼狩猎者,武陵仙君,永耀之星,魔法小厨娘,如梦令,白鹤梁神女,天狼征服者,李逍遥,神威,天魔缭乱,引擎之心,龙胆,辉光之辰,冰锋战神,淬星耀世,永曜之星,白昼王子,云霓雀翎,伽罗太华,一念神魔,暗影游猎,武圣,朔望之晖,零号·赤焰,白晶晶,时雨天司,祈雪灵祝,牛魔奔雷神使,御风骁将,匿光追影者,沙漠行僧,黎明之约,火炮绅士,寅虎·瑞焰,寅虎·心曲,寅虎·赤拳,寅虎·展翼,寅虎·御盾,星域神启,时之祈愿,补天,挚爱花嫁,挚爱之约,玩趣恶龙,祁雪灵祝,冰封战神,默契交锋,默契交锋,奔雷神使,天狼运算者,蔷薇恋人,美猴王,职棒王牌,优雅恋人,嘻哈天王";
                String [] string3s = string3.split(",");
                String xdpf = "";
                for(String s : string3s){
                    if(accountInfo.getDes().contains(s)){
                        xdpf+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(xdpf)){
                    att.put("限定皮肤",xdpf.substring(1));
                }
                String string4 = "胡桃夹子,拒霜思,潮玩牛仔,幻夜卜梦,女儿国国王,傲雪梅枪,无双福将,虎啸剑宗,雪上飞焰,时之愿境,时之祈愿,月团寄思,乐园奇幻夜,暗渊魔法,孙行者,猪悟能,高山流水,真爱魔法,时之奇旅,遇见胡璇,遇见神鹿,地狱火,黄金狮子座,炽阳神光,地狱之眼,绛天战甲,祈雪灵祝,久胜战神,猫影幻舞,仲夏夜之梦,飞鸢探春,超时空战士,胖达荣荣,游龙清影,黄金白羊座,冠军飞将,海洋之心,云鹰飞将,黄金射手座,时之恋人,音你心动,默契交锋,猫狗日记,末日机甲,启明星使,乞巧织情,苍穹之光,电玩小子,龙骑士,暗夜猫娘,白龙吟";
                String[] string4s = string4.split(",");
                String xxypf = "";
                for(String s : string4s){
                    if(accountInfo.getDes().contains(s)){
                        xxypf+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(xxypf)){
                    att.put("稀有皮肤",xxypf.substring(1));
                }
                if (Objects.equals("有二次",accountInfo.getLevel())){
                    att.put("二次实名","可改实名");
                }else{
                    att.put("二次实名","不可改实名");
                }
                att.put("营地ID",accountInfo.getDes().substring(accountInfo.getDes().indexOf("营地号")+3,accountInfo.getDes().indexOf("-")));
                attrs.add(att);
            }else if("和平精英".equals(accountInfo.getType())){
                att.put("套装数量",accountInfo.getSuit());
                att.put("枪皮数量",accountInfo.getGuns());
                String string = "热血青铜,不屈白银,英勇黄金,坚韧白金,不朽星钻,荣耀皇冠,超级王牌,无敌战神";
                String[]strings = string.split(",");
                String dw = "";
                for (String s: strings) {
                    if(accountInfo.getDes().contains(s)){
                        dw=s;
                        break;
                    }
                }
                if(StringUtils.isNotEmpty(dw)){
                    att.put("段位",dw);
                }
                String string1 = "山经魅狐,童趣迷兔,炙焰红王,苍蓝魅影,翡翠骑士,绚金战神,甜蜜誓约,梦幻火箭,金属狂野,精灵氛围,智能音符,缤纷油彩,放客神游,金凤玉露,麻辣鲜香锅,天启纪元,星之信仰,华贵君王,精灵迷巫,蝴蝶迷情,雪国梦幻,守护骑士,火曜朱雀,水曜玄武,土曜战麟,木曜青龙,金曜白虎,银河机甲,天使彩虹糖,宝贝奶油派,甜心巧克力,荒野猎神,南瓜骑士,粉色回忆,数码大师,极限特训,未来战士,星之漫游者,深渊皇后,快乐主宰,幻影战神";
                String[]string1s = string1.split(",");
                String xytz = "";
                for (String s: string1s) {
                    if(accountInfo.getDes().contains(s)){
                        xytz+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(xytz)){
                    att.put("稀有套装",xytz.substring(1));
                }
                String string2 = "兰博基尼SVJ(铂),兰博基尼,兰博基尼SVJ(绿),兰博基尼SUV(铂),兰博基尼SUV(黄),兰博基尼SUV(金),兰博基尼Est(铂),兰博基尼Est(金),兰博基尼Est( 灰),焰龙咆哮,海龙奔腾,金龙耀世,萌喵橘座,灵鼠银迹,鬼马风驰,阿斯顿马丁X橙,阿斯顿马丁S金,阿斯顿马丁S绿,阿斯顿马丁S红,阿斯顿马丁X金,阿斯顿马丁X蓝,Model X银,Model X紫,Model X白,Model 3银,Model 3紫,Model 3白,玛莎拉蒂蓝,玛莎拉蒂粉,玛莎拉蒂金,双人摩托梦幻火箭,合金龙骨蓝,合金龙骨绿,合金龙骨红,空客-蔚蓝之翼,空客-恋语之翼,双刃魅影(绿),双刃魅影(金),双刃魅影(红),特斯拉水滴蓝,特斯拉沁心粉,特斯拉尊贵铂,特斯拉极昼黑,特斯拉荒芜蓝,特斯拉镭光铂,快艇塞拉深潜蓝,快艇塞拉霓虹粉,快艇塞拉鲸之蓝";
                String[] string2s = string2.split(",");
                String rmzj = "";
                for (String s:string2s){
                    if(accountInfo.getDes().contains(s)){
                        rmzj+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(rmzj)){
                    att.put("热门载具",rmzj.substring(1));
                }
                String string3 = "爆炸猎弓,M417射手步枪,M416火箭少女,M416心之恋语,AKM影袭,SCARL银河战甲,SCARL致命红樱,SCARL梦幻火箭,SCARL扶摇飞仙,AUG幻影战神,AUG甜蜜菠萝,AUG魅夜紫皇,M762魅夜紫皇,G36C花间之火,Kar98K伏魔圈,Kar98K幻影战神,Kar98K魅夜紫皇,M24星之信仰,AWM花间之火,SKS心之恋语,SKS金玉无双,Mini龙虾霸霸,UZl幻影战神,UZI金玉无双,UZ";
                String[] string3s = string3.split(",");
                String rmqp = "";
                for (String s:string3s){
                    if(accountInfo.getDes().contains(s)){
                        rmqp+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(rmqp)){
                    att.put("热门枪皮",rmqp.substring(1));
                }
                String string4 = "春暖花开,夜王,精灵迷巫,霓虹街区,梦幻火箭,至尊龙雀,童趣迷兔";
                String[] string4s = string4.split(",");
                String xyfxq = "";
                for (String s:string4s){
                    if(accountInfo.getDes().contains(s)){
                        xyfxq+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(xyfxq)){
                    att.put("稀有飞行器",xyfxq.substring(1));
                }
                if (Arrays.asList(LCConstant.haveTwoList).contains(accountInfo.getLevel())) {
                    att.put("是否二次","可二次");
                } else {
                    att.put("是否二次","不可二次");
                }
                attrs.add(att);
                params.put("attrs",attrs);
            }else if("英雄联盟".equals(accountInfo.getType())){
                att.put("英雄数量",accountInfo.getHeroes());
                att.put("皮肤总数量",accountInfo.getSkins());
                att.put("皮肤总数量",accountInfo.getSkins());
                String string = "黑铁,青铜,白银,黄金,铂金,钻石,大师,宗师,王者";
                String[] strings = string.split(",");
                String dw = "";
                if(!string.contains(accountInfo.getLevel().replace("白金","铂金"))) {
                    for (String s : strings) {
                        if (accountInfo.getDes().contains(s)) {
                            dw = s;
                            break;
                        }
                    }
                }else{
                    dw = accountInfo.getLevel().replace("白金","铂金");
                }
                if(StringUtils.isNotEmpty(dw)){
                    att.put("单双排段位",dw);
                }
                String string1 = "盲僧-龙的传人,酒桶-冰原核弹,流浪-致死不渝,龙龟-国王龙龟,蛮王-诸神黄昏,武器-万夫莫开,卡尔玛-莲花之令,亚索-黑夜使者";
                String[] string1s = string1.split(",");
                String des = accountInfo.getDes().replace("龙瞎","龙的传人盲僧").replace("龙的传人","龙的传人盲僧");
                String xypf = "";
                for(String s : string1s){
                    String[] ss = s.split("-");
                    if(des.contains(ss[1])){
                        xypf+=","+ss[1]+"-"+ss[0];
                    }
                }
                if(StringUtils.isNotEmpty(xypf)){
                    att.put("稀有皮肤",xypf.substring(1));
                }
                String string2 = "EZ-未来战士,DJ娑娜,乌迪尔-灵魂守卫,拉克丝-大元素使,厄运小姐-武装战姬,刀妹-源计划,亚索-黑夜使者";
                String[] string2s = string2.split(",");
                String rmpf = "";
                String dess = accountInfo.getDes().replace("伊泽瑞尔","EZ");
                for(String s : string2s){
                    if(s.contains("-")) {
                        String[] strings1 = s.split("-");
                        if (dess.contains(s)) {
                            rmpf += "," + strings1[1]+"-"+strings1[0];
                        }
                    }else{
                        rmpf+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(rmpf)){
                    att.put("热门皮肤",rmpf.substring(1));
                }
                String string3 = "诺手-恐惧新星,VN-摄魂使者,嘉文四世-海克斯,轮子妈-新创战纪,人马-零号骑兵,大嘴-海克斯,马尔扎-哈海克斯,雷克-顿海克斯,牛头-海克斯,斯维因-海克斯,阿木木-海克斯,波比-海克斯,龙龟-海克斯,安妮-海克斯,猪妹-海克斯,魔腾-海克斯";
                String[] string3s = string3.split(",");
                String hksxl = "";
                for(String s : string3s){
                    String desss = accountInfo.getDes().replace("德莱厄斯","诺手").replace("皇子","嘉文四世");
                    String[] ss = s.split("-");
                    if(desss.contains(ss[1]+ss[0])){
                        hksxl+=","+ss[1]+"-"+ss[0];
                    }
                }
                if(StringUtils.isNotEmpty(hksxl)){
                    att.put("海克斯系列",hksxl.substring(1));
                }
                String string4 = "盲僧-黑夜使者,至臻盖伦,瑞文-武剑仙,女警-电玩女神,萨勒芬妮KDA,剑魔-腥红之月,卡莎KDA,拉克丝-战争学院,VN-烈焰美人,女枪-万圣节,锤石-未来战士,小鱼人-毛绒狗,寡妇KDA,妮寇-星之守护者,阿狸KDA,阿卡丽KDA,琪亚娜-真实伤害,赛娜-真实伤害,大虫子-暗星,石头人-死兆星,佐伊-奥术师,卡尔玛-莲花之令,婕拉-魔女,卢锡安-未来战士,提莫-灵魂莲华,瑟提-神龙尊者,亚索-真实伤害";
                String[] string4s = string4.split(",");
                String zzxl = "";
                for(String s : string4s){
                    if(!s.contains("-")){
                        zzxl+=","+s;
                    }else {
                        String[] ss = s.split("-");
                        if (accountInfo.getDes().contains(ss[1] + ss[0])) {
                            zzxl += "," + ss[1] + ss[0];
                        }
                    }
                }
                if(StringUtils.isNotEmpty(zzxl)){
                    att.put("至臻系列",zzxl.substring(1));
                }
                String string5 = "大嘴-醒狮,男刀-银龙裁决,猴子-定海神针,盲僧-龙的传人,琴女-古琴余韵,蛇女-碧玉之牙,安妮-我的熊猫,库奇-神龙之翼,皎月-嫦娥,锐雯-花木兰,金克斯-神龙烈焰,沙皇-鸡年限定,盖伦-张辽,蔚-虎痴之拳,拉克丝-春晖女神,狼人-南天之威,狗头-北辰之怒,猪妹-金猪烈焰,VN-烈焰美人,塔姆-纳财大帝,瑟提-王国机神苍狼,贾克斯-王国机神白虎,德莱文-王国机神青龙,蕾欧娜-王国机神朱雀,盖伦-王国机神玄武";
                String[] string5s = string5.split(",");
                String nxpf = "";
                for(String s : string5s){
                    if(s.contains("-")){
                        String[] ss = s.split("-");
                        if(accountInfo.getDes().contains(ss[1]+ss[0])){
                            nxpf += "," + ss[1]+ss[0];
                        }
                    }
                }
                if(StringUtils.isNotEmpty(nxpf)){
                    att.put("年限皮肤",nxpf.substring(1));
                }
                String s = accountInfo.getDes();
                if(s.contains("炫彩")) {
                    String str1 = "";
                    if (!"/".equals(s.substring(s.indexOf("皮肤") + 2, s.indexOf("皮肤") + 3))) {
                        str1 = s.substring(s.indexOf("皮肤") + 2, s.indexOf("炫"));
                    } else {
                        str1 = s.substring(s.indexOf("皮肤/") + 3, s.indexOf("炫"));
                    }
                    att.put("炫彩皮肤数量", str1.trim());
                }
                attrs.add(att);
            }else if("原神".equals(accountInfo.getType())){
                String wxjs = "纳西妲,赛诺,妮露,提纳里,夜兰,八重神子,神里绫人,荒泷一斗,阿贝多,申鹤,珊瑚宫心海,雷电将军,宵宫,神里绫华,枫原万叶,胡桃,甘雨,阿贝多,刻晴,莫娜,七七,迪卢克,琴,可莉,温迪,钟离,达达利亚,魈,优菈";
                String[] wxjss = wxjs.split(",");
                String wxjsss ="";
                for(String s : wxjss){
                    if(accountInfo.getDes().contains(s)){
                        wxjsss+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(wxjsss)){
                    att.put("五星角色",wxjsss.substring(1));
                    att.put("5星角色数量",wxjsss.split(",").length);
                }
                String wxwq = "千夜浮梦,赤沙之杖,圣显之钥,猎人之径,薙草之稻光,神乐之真意,若水,波乱月白经津,冬极白星,赤角石溃杵,息灾,不灭月华,苍古自由之誓,雾切之回光,松籁响起之时,飞雷之弦振,终末嗟叹之诗,斫峰之刃,阿莫斯之弓,天空之翼,四风原典,天空之卷,和璞鸢,天空之脊,狼的末路,天空之傲,天空之刃,风鹰剑,尘世之锁,无工之剑,贯虹之槊,磐岩结绿,护摩之杖";
                String[] wxwqs = wxwq.split(",");
                String wxwqss ="";
                for(String s : wxwqs){
                    if(accountInfo.getDes().contains(s)){
                        wxwqss+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(wxwqss)){
                    att.put("五星武器",wxwqss.substring(1));
                    att.put("5星武器数量",wxwqss.split(",").length);
                }
                attrs.add(att);
            }else if("CF端游".equals(accountInfo.getType())){
                /*String des = accountInfo.getDes();
                String string = "";
                if("可".equals(des.substring(des.indexOf("V/")+2,des.indexOf("V/")+3))) {
                    string = des.substring(des.indexOf("排位/") + 3, des.indexOf("V/"));
                }else{
                    string = des.substring(des.indexOf("区/") + 2, des.indexOf("V/"));
                }
                if(Integer.parseInt(string)>=1&&Integer.parseInt(string)<=5){
                    att.put("英雄级武器","1-5V");
                }else if(Integer.parseInt(string)>=6&&Integer.parseInt(string)<=10){
                    att.put("英雄级武器","6-10V");
                }else if(Integer.parseInt(string)>=11&&Integer.parseInt(string)<=20){
                    att.put("英雄级武器","11-20V");
                }else if(Integer.parseInt(string)>=20&&Integer.parseInt(string)<=30){
                    att.put("英雄级武器","20-30V");
                }else if(Integer.parseInt(string)>=30&&Integer.parseInt(string)<=50){
                    att.put("英雄级武器","30-50V");
                }else if(Integer.parseInt(string)>=50&&Integer.parseInt(string)<=70){
                    att.put("英雄级武器","50-70V");
                }else if(Integer.parseInt(string)>70){
                    att.put("英雄级武器","70V以上");
                }*/
                String vq = "9A91-烈火,AK12-天启,AK47-黑鲨,AK47-黑武士,AK47-火麒麟,AK47-机械迷城,AK47-雷暴,AK47-麒麟,AK47-无影,AN94-超新星,AWM-裁决,AWM-天龙,Barrett-毁灭,Barrett-极光,Barrett-雷霆,Barrett-朱雀,COP357-雷霆,COP-堕天神,Glock18-武圣,HK417-朱雀,M200-幻神,M4A1-堕天神,M4A1-黑龙,M4A1-黑骑士,M4A1-雷神,M4A1-雷霆,M4A1-猎神,M4A1-龙血,M4A1-玫瑰精灵,M4A1-千变,M4A1-青龙,M4A1-死神,M4A1-武圣,M4A1-夜魔,QBZ95-幻兽,RPK-盘龙,Scar-白虎,USP-雷暴,传说暗裔,传说光耀,炼狱,加特林-夜魔,破空枪刃-,沙鹰-幻兽,沙鹰-天神,沙鹰-修罗,汤姆逊-烈龙";
                String [] vqs = vq.split(",");
                String ss = "";
                for(String s : vqs){
                    if(accountInfo.getDes().contains(s.replace("-",""))){
                        ss+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(ss)) {
                    att.put("V枪", ss.substring(1));
                }
                String myjs = "凌霄,迷迭香,春,炫,魅影,蝴蝶,瞳,樱,葵,零,审判者";
                String [] myjss = myjs.split(",");
                String sss = "";
                for(String s : myjss){
                    if(accountInfo.getDes().contains(s.replace("-",""))){
                        sss+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(sss)) {
                    att.put("命运角色",sss.substring(1));
                }
                attrs.add(att);
            }else if("CF手游".equals(accountInfo.getType())){
                String string = "王者之势,王者之光,王者之心,王者之魄,王者之怒,王者之影,王者之锋,王者之魂,王者之翼,王者之戮,王者之力,王者之烈,王者之武,王者之啸,王者之灵,王者之击,王者之轮,王者之魄冠军珍藏,王者之影冠军珍藏,王者之心冠军奇迹,王者之心冠军情久,王者之怒冠军奇迹,王者之影冰霜奇迹,王者之锋冰霜奇迹,王者魄影冰霜奇迹";
                String[] strings = string.split(",");
                String wzwq = "";
                for(String s : strings){
                    if(accountInfo.getDes().contains(s)){
                        wzwq+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(wzwq)){
                    att.put("王者武器",wzwq.substring(1));
                }
                String string1 = "QBZ03-湮灭,双持斯泰尔天使,剑齿虎,AK12天启,QBZ03金色蔷薇,MG36黑骑士,MK5机械纪元,AK47沙漠领主,加特林堡垒,汤姆逊烈龙,M13EBR暗夜,M4A1XS赤龙,暗杀星,09式狙天神,9A91游骑兵,95K黑骑士,KSG黑骑士,M200幻神,AK47无影葵,AK47变色龙,巴雷特变色龙,双持沙鹰变色龙,双持柯尔特极光,AWM妙才,蟒蛇妙才,COP357星像,气手枪炼狱,加特林堡垒觉醒,王者之烈,QBZ95幻影,沙鹰幻兽,亡命之徒幻兽,09式狙幻兽,斯泰尔幻兽,QSZ92金色蔷薇,王者之武,SCAR幽暗骑士觉醒,M4A1变色龙,AWM游骑兵,CZ75死神,M4A1武神,加特林炼狱,GLOCK18武圣,沙鹰游骑兵,王者之影,王者之灵,AK47游骑兵,M4A1沙漠领,AK47冰魄,AK47冰魂觉醒主,COP357雷神,王者之心,王者之怒,AN94超新星,沙鹰无影,王者之魄珍藏,王者之魄冠军,王者之魂,沙鹰天神,AK47火麒麟,沙鹰火麒麟,9A91死神,AK47黑武士,AK47黑武士觉,左轮黑武士,左轮黑武士觉醒,黑龙魂,AK火麒麟,AK黑武士,AK无影,AK47齐天大圣,AK47枪王荣耀,AK47苍龙,AK47青花瓷,AK角斗士,M4A1雷神,M4A1战龙,M4A1黑龙,M4A1死神,M4A1游骑兵,M4A1玫瑰精灵,M4A1SS,枪娘";
                String[] string1s = string1.split(",");
                String tswq = "";
                for(String s : string1s){
                    if(accountInfo.getDes().contains(s)){
                        tswq+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(tswq)){
                    att.put("特殊武器",tswq.substring(1));
                }
                String string2 = "蝴蝶,葵,樱,零,萝拉,潘多拉,兰,灵狐者,猎狐者,白狼,刀锋,战魔,巫医,分裂者,灵魂忍者,妖姬,疯狂宝贝,绿巨人,零";
                String[] string2s = string2.split(",");
                String rwjs = "";
                for(String s : string2s){
                    if(accountInfo.getDes().contains(s)){
                        rwjs+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(rwjs)){
                    att.put("人物角色",rwjs.substring(1));
                }
                attrs.add(att);
            }else if("火影忍者".equals(accountInfo.getType())){
                if(accountInfo.getDes().contains("S忍者")) {
                    att.put("S忍数量", accountInfo.getDes().substring(accountInfo.getDes().indexOf("S忍者")+3,accountInfo.getDes().indexOf("个")));
                }
                if(accountInfo.getDes().contains("A忍者")) {
                    att.put("A忍数量", accountInfo.getDes().substring(accountInfo.getDes().indexOf("A忍者")+3,accountInfo.getDes().indexOf("个")));
                }
                String string = "自来也,自来也-仙人模式,大蛇丸,纲手,纲手-百豪,波风水门,波风水门-秽土转生,猿飞日斩,猿飞日斩-秽土转生,千手扉间-秽土转生,千手扉间,千手柱间,宇智波斑,宇智波鼬-须佐能乎,神秘面具男,鬼灯幻月-二代目水影,艾-四代目雷影,金角银角-秽土转生,大野木-三代目土影,无-二代目土影,半藏-秽土转生,佩恩-天道,长门-秽土转生,宇智波斑-白面具,千手柱间-秽土转生,自来也-舞之豪杰,佩恩天道-超,药师兜-仙人模式,宇智波斑-秽土转生,艾-三代目雷影";
                String[] strings = string.split(",");
                String sr = "";
                for(String s : strings){
                    if(accountInfo.getDes().contains(s)){
                        sr+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(sr)){
                    att.put("S忍",sr.substring(1));
                }
                String string1 = "漩涡鸣人仙人模式,旋涡鸣人九尾查克拉,佐助万花筒写轮眼,佐助疾风传咒印,春野樱百豪,秋道丁次忍者大战,旗木卡卡西,卡卡西万花筒写轮眼,迈特凯,迈特卡惊门,猿飞阿斯玛,猿飞阿斯玛秽土转生,地陆,宇智波止水,志村团藏,猿飞日斩火影继承人,波风水门新春限定,我爱罗疾风传,我爱罗忍者大战,勘九郎忍者大战,钱袋近松十人卫,照美冥五代目水影,照美冥夏日泳装,桃地再不斩,奇拉比,达鲁伊,三船,药师兜半蛇斗篷,小南,小南夏日泳装,绝,角都,角都晓创生,角都地怨虞,大蛇丸晓,蝎,蝎百机操演,宇智波鼬,宇智波鼬新春限定,干柿鬼鲛,干柿鬼鲛鲛肌融合,迪达拉,阿飞,飞段,飞段死司凭血,宇智波带土暴怒,黄土忍界大战,猿飞木叶丸博人传,并足雷同,春野樱冬日祭,旗木卡卡西忍界大战,蝎[晓创生],鹿丸[新春限定],小南[新春限定],飞段恶灵之影,宇智波佐助须佐能乎,加藤断,佐助疾风传咒,千代近松十人卫,药师兜半蛇斗篷";
                String[] string1s = string1.split(",");
                String ar = "";
                for(String s : string1s){
                    if(accountInfo.getDes().contains(s)){
                        ar+=","+s;
                    }
                }
                if(StringUtils.isNotEmpty(ar)){
                    att.put("A忍",ar.substring(1));
                }
                attrs.add(att);
            }
            params.put("attrs",attrs);
            /*List<JSONObject> attrs = new ArrayList<>();
            JSONObject att = new JSONObject();
            att.put("段位",accountInfo.getLevel());
            attrs.add(att);
            params.put("attrs",attrs);*/

            InfoImg infoImg = new InfoImg();
            infoImg.setInfoId(accountInfo.getId());
            infoImg.setType(Constants.STR_1);
            List<InfoImg> infoImgs = infoImgMapper.selectInfoImgList(infoImg);
            List<Map<String,Object>> imgParam = new ArrayList<>();
            for (InfoImg img : infoImgs) {
                Map<String,Object> imgMap = new HashMap<>();
                imgMap.put("url",img.getImgUrl());
                imgParam.add(imgMap);
            }
            if (CollectionUtils.isEmpty(imgParam)){
                Map<String,Object> imgMap = new HashMap<>();
                imgMap.put("url", this.salePartner.getTwoOther());
                imgParam.add(imgMap);
            }
            params.put("medias",imgParam);
            params.put("out_goods_id",accountInfo.getId());
            return params;
        }else {
            throw new GlobalException("游戏类型不对，当前类型" + accountInfo.getType());
        }
    }


    /**
     * ys 元神
     * pubg 和平精英
     * wzry 王者荣耀
     * yjwj 永劼无间
     * lolm lol手游
     * lol lol端游~~~~
     */
    private String getEngGameType(String gameName){
        switch (gameName){
            case "王者荣耀":
                return "wzry";
            case "原神":
                return "ys";
            case "和平精英":
                return "pubg";
            case "永劼无间":
                return "yjwj";
            case "英雄联盟手游":
                return "lolm";
            case "英雄联盟":
                return "lol";
            case "CF端游":
                return "cf";
            case "CF手游":
                return "cfm";
            case "火影忍者":
                return "hyrz";
            default:
                return null;
        }
    }

    public static void main(String[] args) {
        String string1 = "【有二次实名资格】CF070/山东1区/37V/可排位/幻神+黄忠枪皮/传说辉光/传说暗裔/QBZ-金色蔷薇.黑骑士X2.极光音效卡/雨棠/火麒麟/黑龙/雷神/黑骑士/死神/青龙/朱雀/天龙/毁灭/极光/18枪皮";
        if(!"可".equals(string1.substring(string1.indexOf("V/")+2,string1.indexOf("V/")+3))) {
            System.out.println(string1.substring(string1.indexOf("排位/") + 3, string1.indexOf("V/")));
        }else{
            System.out.println(string1.substring(string1.indexOf("区/") + 2, string1.indexOf("V/")));
        }
    }
}
